﻿using System.Runtime.InteropServices;

namespace OnDash.Core;

public static class Utils
{
    public static void Swap<T>(ref T left, ref T right)
    {
        (left, right) = (right, left);
    }

    public static IntPtr StringToCoTaskMemUtf8(string str) =>
        Marshal.StringToCoTaskMemUTF8(str);

    public static unsafe string PtrToStringUtf8(byte* ptr) =>
        Marshal.PtrToStringUTF8((IntPtr)ptr)!;
}